Skip to content

fix(installer): detect existing Homebrew and persist shellenv#41

Merged
fullstackjam merged 1 commit intomainfrom
claude/eloquent-swirles-dde831
Apr 21, 2026
Merged

fix(installer): detect existing Homebrew and persist shellenv#41
fullstackjam merged 1 commit intomainfrom
claude/eloquent-swirles-dde831

Conversation

@fullstackjam
Copy link
Copy Markdown
Collaborator

Summary

Fixes a reinstall-loop bug in scripts/install.sh that made curl openboot.dev/<user> | bash fail on the second run.

The bug

  1. First run installs Homebrew at /opt/homebrew, but the installer script never wrote eval "$(brew shellenv)" to ~/.zprofile — Homebrew's official installer only prints that as a hint.
  2. In a fresh shell (or a second curl | bash), /opt/homebrew/bin is not on PATH, so command -v brew returns false.
  3. The script re-runs Homebrew's installer, which sees /opt/homebrew already exists and executes sudo chown -R ... /opt/homebrew.
  4. That chown fails with Operation not permitted on SIP-protected signed .app bundles inside Caskroom/ (e.g. wetype), and set -e aborts the whole script.

Fix

  • Probe /opt/homebrew/bin/brew and /usr/local/bin/brew before calling the Homebrew installer. If found, eval "$(brew shellenv)" and return.
  • After a fresh Homebrew install, append eval "$(/opt/homebrew/bin/brew shellenv)" to ~/.zprofile (idempotent via grep -qF) so future shells find brew on PATH.
  • Replace the manual PATH / HOMEBREW_PREFIX / HOMEBREW_CELLAR / HOMEBREW_REPOSITORY exports with brew shellenv, which is the canonical way.

Test plan

  • Run curl openboot.dev/<user> | bash on a Mac with Homebrew already installed but not on PATH → should detect it and skip reinstall.
  • Run curl openboot.dev/<user> | bash on a fresh Mac without Homebrew → should install, add line to ~/.zprofile, and not duplicate on re-run.
  • Verify ~/.zprofile does not get duplicate entries across multiple runs.

…profile

When `curl | bash` was re-run in a fresh shell, `command -v brew` failed
because Homebrew's PATH was never written to ~/.zprofile. The script then
tried to reinstall Homebrew, which runs `chown -R /opt/homebrew` and fails
on SIP-protected signed .app bundles in Caskroom (e.g. wetype).

- Probe /opt/homebrew/bin/brew and /usr/local/bin/brew before reinstalling
- Append `eval "$(brew shellenv)"` to ~/.zprofile after a fresh install so
  subsequent shells find brew on PATH
- Replace manual PATH/HOMEBREW_* exports with `brew shellenv`
@github-actions
Copy link
Copy Markdown

👋 Thanks for opening this pull request!

Before merging:

  • Code follows existing patterns in the codebase
  • go build ./... and go vet ./... pass
  • Commit message is clear and descriptive

@fullstackjam will review this soon. Thanks for contributing! 🚀

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullstackjam fullstackjam merged commit 15aa23b into main Apr 21, 2026
9 of 10 checks passed
@fullstackjam fullstackjam deleted the claude/eloquent-swirles-dde831 branch April 21, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant